#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
unsigned int mp[N][N];
int mp1[N][N];
int n,m;
mt19937 mt;
int res[N*2];
map<pair<unsigned int,unsigned int>,vector<vector<int>>> avl;
void dfs(int p){
    if(p > n + m){
        for(int i = 1;i<=m;i++){
            for(int j = 1;j <= res[i];j++){
                mp1[i][j]++;
            }
        }
        for(int i = 1;i<=n;i++){
            for(int j = 1;j <= res[i + m];j++){
                mp1[j][i]++;
            }
        }
        unsigned int v1 = 0,v2 = 0;
        for(int i = 1;i<=m;i++){
            for(int j = 1;j <= n;j++){
                if(mp1[i][j] == 1){
                    v1 ^= mp[i][j];
                }
                if(mp1[i][j] == 2){
                    v2 ^= mp[i][j];
                }
                mp1[i][j] = 0;
            }
        }
        vector<int> r1;
        for(int i = 1;i <= n + m;i++){
            r1.push_back(res[i]);
        }
        if(avl.find(make_pair(v1,v2)) != avl.end()){
            avl[make_pair(v1,v2)].push_back(r1);
        }else{
            avl[make_pair(v1,v2)] = vector<vector<int>>();
            avl[make_pair(v1,v2)].push_back(r1);
        }
        return;
    }
    if(p <= m){
        for(int i = 0;i <= n;i++){
            res[p] = i;
            dfs(p + 1);
        }
    }else{
        for(int i = 0;i <= m;i++)
        {
            res[p] = i;
            dfs(p + 1);
        }
    }
}
int main(){
    cin>>n>>m;
    for(int i = 1;i<=n;i++){
        for(int j = 1;j <= m;j++){
            mp[i][j] = mt();
        }
    }
    dfs(1);
    for(pair<pair<unsigned int,unsigned int>,vector<vector<int>>> vl : avl){
        vector<vector<int>> v = vl.second;
        cout<<"----------------------------------------------\n";
        for(vector<int> tv : v){
            for(int pl : tv){
                cout<<pl<<' ';
            }
            cout<<'\n';
        }
    }

}